package com.jeesite.modules.dataScreen.service;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeesite.modules.dataScreen.dao.IndustryIndexRealtimeYqDao;
import com.jeesite.modules.dataScreen.domain.monitoring.IndustryIndexRealtimeYq;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 舆情指标数据同步到底座的表
 *
 * @author machenzhi
 * @date 2024/07/02 10:03
 */
@Service
public class IndustryIndexRealtimeYqService extends ServiceImpl<IndustryIndexRealtimeYqDao, IndustryIndexRealtimeYq> {


    /**
     * 根据指标名称更新指标值
     *
     * @param indexRealtimeYqs
     */
    public void updateValueByName(List<IndustryIndexRealtimeYq> indexRealtimeYqs) {
        Date date = new Date();
        for (IndustryIndexRealtimeYq yq : indexRealtimeYqs) {
            LambdaUpdateWrapper<IndustryIndexRealtimeYq> updateWrapper = new LambdaUpdateWrapper<>();
            updateWrapper.eq(IndustryIndexRealtimeYq::getIndicatorName, yq.getIndicatorName());
            updateWrapper.set(IndustryIndexRealtimeYq::getIndicatorValue, yq.getIndicatorValue());
            updateWrapper.set(IndustryIndexRealtimeYq::getUpdateTime, date);
            this.update(updateWrapper);
        }
    }
}
